#include "stm32f10x.h" // Device header
#include "HCSR04.h"
#include "Serial.h"

volatile float distance;

int main(void)
{
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);    // 设置系统中断优先级分组为2

  Serial_Init();
  SR04_Init();
  
  while (1)
  {
    distance = SR04_MeasureDistance();          // 获取距离
    Serial_Printf(".2f cm\r\n", distance);      // 串口打印
    Delay_ms(100);
  }
}


